
function toBoolean(val) {
  if (typeof val === 'boolean') return val
  if (val === '') return val
  return val === 'true' || val == '1'
}

function cookieToJson(cookie) {
  if (!cookie) return {}
  const cookieArr = cookie.split(';')
  const obj = {}
  cookieArr.forEach(i => {
    const arr = i.split('=')
    obj[arr[0]] = arr[1]
  })
  return obj
}

export { toBoolean, cookieToJson }